package com.ruoyi.team.trash.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.team.trash.domain.AchievementTrash;
import com.ruoyi.team.trash.domain.vo.AchievementTrashVO;
import com.ruoyi.team.trash.service.IAchievementTrashService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 成果移除箱Controller
 *
 * @author ruoyi
 * @date 2025-01-24
 */
@RestController
@RequestMapping("/team/trash")
public class AchievementTrashController extends BaseController
{
    @Autowired
    private IAchievementTrashService achievementTrashService;

    /**
     * 查询成果移除箱列表
     */
    @PreAuthorize("@ss.hasPermi('team:trash:list')")
    @GetMapping("/list")
    public TableDataInfo list(AchievementTrash achievementTrash)
    {
        startPage();
        List<AchievementTrashVO> list = achievementTrashService.selectAchievementTrashList(achievementTrash);
        return getDataTable(list);
    }

    /**
     * 导出成果移除箱列表
     */
    @PreAuthorize("@ss.hasPermi('team:trash:export')")
    @Log(title = "成果移除箱", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AchievementTrash achievementTrash)
    {
//        List<AchievementTrash> list = achievementTrashService.selectAchievementTrashList(achievementTrash);
//        ExcelUtil<AchievementTrash> util = new ExcelUtil<AchievementTrash>(AchievementTrash.class);
//        util.exportExcel(response, list, "成果移除箱数据");
    }

    /**
     * 获取成果移除箱详细信息
     */
    @PreAuthorize("@ss.hasPermi('team:trash:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(achievementTrashService.selectAchievementTrashById(id));
    }

    /**
     * 新增成果移除箱
     */
    @PreAuthorize("@ss.hasPermi('team:trash:add')")
    @Log(title = "成果移除箱", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AchievementTrash achievementTrash)
    {
        return toAjax(achievementTrashService.insertAchievementTrash(achievementTrash));
    }

    /**
     * 修改成果移除箱
     */
    @PreAuthorize("@ss.hasPermi('team:trash:edit')")
    @Log(title = "成果移除箱", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AchievementTrash achievementTrash)
    {
        return toAjax(achievementTrashService.updateAchievementTrash(achievementTrash));
    }

    /**
     * 删除成果移除箱
     */
    @PreAuthorize("@ss.hasPermi('team:trash:remove')")
    @Log(title = "成果移除箱", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(achievementTrashService.deleteAchievementTrashByIds(ids));
    }
}
